﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace engine
{
    static class FpsMeter
    {
        private static int frames;
        private static int framesPerSecond = 1;
        private static double ElapsedTimeSec;

        public static int CountFPS(GameTime gametime)
        {
            ElapsedTimeSec += gametime.ElapsedRealTime.TotalSeconds;

            if (ElapsedTimeSec > 1.0)                                   // Basic method for measuring FPS, increment frame count until a second has elapsed.
            {
                framesPerSecond = frames;
                frames = 0;
                ElapsedTimeSec = 0.0;
                return framesPerSecond;
            }
            else
            {
                ++frames;
                return framesPerSecond;
            }

            
        }
    }
}
